import React, { PureComponent } from 'react';
import S from './index.m.less';

export default class Tab extends PureComponent {
    static defaultProps = {
        showTopScreenNum: 2,
    };

    state = {
        showDiv: false, // 展示
    };

    componentWillReceiveProps() {}

    handleTest = () => {
        console.log('调用test');
    };

    handleTest2() {
        console.log('调用test2');
    }

    setTimeTest = callback => {
        setTimeout(() => {
            callback && callback();
        }, 1000);
    };

    // 定时器
    setInterRun = callback => {
        setInterval(() => {
            callback && callback();
        }, 1000);
    };

    render() {
        const { showDiv } = this.state;
        const { showTopScreenNum } = this.props;

        return (
            <div className="foo">
                <a>标题</a>
                <p className={S.tab}>
                    props传递：
                    {showTopScreenNum}
                </p>
                {showDiv && <div className="show">state展示1</div>}
                <button className="button" onClick={this.props.clickBtn}>
                    按钮点击
                </button>
            </div>
        );
    }
}
